
var msg = false;


function add_msg(text)
{
    $('ul#messages').css("position", "fixed");
    
    function show_text() {
        $('ul#messages').html('<li>' + text + '</li>');
    
        $('ul#messages').animate({ top: "0em" }, 1000);
        
        setTimeout(function()
                    { 
                       $('ul#messages').animate({ top: "-1.5em" }, 1000);
                       msg=false;
                    }, 5000);

        msg = true;
    
    }
    //$('ul#messages').hide();
    //$('ul#messages').css("top", "-1.5em");
    if (msg)
       $('ul#messages').animate({ top: "-1.5em" }, 1000, show_text);
    else
       {
         $('ul#messages').css("top", "-1.5em");
         show_text();
       }

   // $('ul#messages').fadeIn("slow");
   // $('ul#messages').show("slow");
   // $('ul#messages').slideDown("fast");
    

}

function ajax_voting()
{    
    $.post(
      
      location.href,  
      $("#potm-form").serialize(),
      function(text, status){
     
         add_msg(text);
         $("#potm-form").remove();
    
      }  
    );  
    
    return false;  

    
}

function ajax_subscribe(link)
{
    $.get(link.href, function(text){
         var lines = text.split("\n", 2);
         
         add_msg(lines[0]);
    
         if (lines[1] != "") 
            $(link).after(lines[1]).remove();
    
        });
    
}

function localtime(ms, obj){
    dt = new Date();
    dt.setTime(ms);
    off = dt.getTimezoneOffset()/-60;
    off = (off ? off : "");
    obj.innerHTML =  dt.toLocaleString()+" (GMT"+(off>0 ? "+" : "")+off+"h) "
    }
    
//function toggleSidebar(){
//   // $("#recent-releases-list ul").slideToggle(1000);
//   $("#recent-releases-list *").toggle();
//   $("#recent-releases-list").animate({ width: "10px"}, 1000);
//   
//    }